<template>
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <!-- 查询区域-END -->

    <!-- 操作按钮区域 -->
    <div class="table-operator">


      <!-- 高级查询区域 -->
    </div>

    <!-- table区域-begin -->
    <div>
  
      <a-table
        ref="table"
        size="middle"
        :scroll="{ x: true }"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        :rowSelection="{ selectedRowKeys: selectedRowKeys, onChange: onSelectChange }"
        class="j-table-force-nowrap"
        @change="handleTableChange"
      >
        <template slot="htmlSlot" slot-scope="text">
          <div v-html="text"></div>
        </template>
        <template slot="imgSlot" slot-scope="text, record">
          <span v-if="!text" style="font-size: 12px; font-style: italic">无图片</span>
          <img
            v-else
            :src="getImgView(text)"
            :preview="record.id"
            height="25px"
            alt=""
            style="max-width: 80px; font-size: 12px; font-style: italic"
          />
        </template>
        <template slot="fileSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px; font-style: italic">无文件</span>
          <a-button v-else :ghost="true" type="primary" icon="download" size="small" @click="downloadFile(text)">
            下载
          </a-button>
        </template>

        <span slot="action" slot-scope="text, record">
          <a-button type="primary" @click="exit(record)">申请准出</a-button>
        </span>
      </a-table>
    </div>

    <zzzs-product-recording-modal ref="modalForm" @ok="modalFormOk"></zzzs-product-recording-modal>
  </a-card>
</template>

<script>
import '@/assets/less/TableExpand.less'
import { mixinDevice } from '@/utils/mixin'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import ZzzsProductRecordingModal from '../productForReference/modules/ZzzsProductRecordingModal'
import { filterMultiDictText } from '@/components/dict/JDictSelectUtil'
import { getAction, postAction } from '../../api/manage';
export default {
  name: 'ZzzsProductRecordingList',
  mixins: [JeecgListMixin, mixinDevice],
  components: {
    ZzzsProductRecordingModal,
  },
  data() {
    return {
      description: '产品备案管理页面',
      // 表头
      columns: [
        {
          title: '#',
          dataIndex: '',
          key: 'rowIndex',
          width: 60,
          align: 'center',
          customRender: function (t, r, index) {
            return parseInt(index) + 1
          },
        },
        {
          title: '产品编号',
          align: 'center',
          dataIndex: 'id',
        },
        {
          title: '产品名称',
          align: 'center',
          dataIndex: 'productName',
        },
        {
          title: '品种',
          align: 'center',
          dataIndex: 'variety',
        },
        {
          title: '产品规格',
          align: 'center',
          dataIndex: 'productStandard',
        },
        {
          title: '产品合格标准',
          align: 'center',
          dataIndex: 'productConformityStandard',
        },
        {
          title: '产地',
          align: 'center',
          dataIndex: 'placeOfOrigin',
        },
        {
          title: '产品介绍',
          align: 'center',
          dataIndex: 'productPresentation',
        },
        {
          title: '状态',
          align: 'center',
          dataIndex: 'status_dictText',
        },
        {
          title: '操作',
          dataIndex: 'action',
          align: 'center',
          fixed: 'right',
          width: 147,
          scopedSlots: { customRender: 'action' },
        },
      ],
      url: {
        list: '/modules/zzzsProductRecording/getExitList',
        exitUrl:"/modules/zzzsProductRecording/applyForExit",
        exportXlsUrl: '/modules/zzzsProductRecording/exportXls',
      },
      dictOptions: {},
      superFieldList: [],
    }
  },
  created() {
    this.getSuperFieldList()
  },
  computed: {
    importExcelUrl: function () {
      return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`
    },
  },
  methods: {
    exit(record) {
      postAction(this.url.exitUrl, {
        id: record.id,
      }).then((res) => {
        console.log(res)
        if (res.success) {
          this.$message.success('申请成功')
        } else {
          this.$message.error('申请失败')
        }
        console.log(this.model)
        this.loadData()
      })
    },
    initDictConfig() {},
    getSuperFieldList() {
      let fieldList = []
      fieldList.push({ type: 'datetime', value: 'updateTime', text: '更新日期' })
      fieldList.push({ type: 'string', value: 'productName', text: '产品名称', dictCode: '' })
      fieldList.push({ type: 'string', value: 'variety', text: '品种', dictCode: '' })
      fieldList.push({ type: 'string', value: 'productStandard', text: '产品规格', dictCode: '' })
      fieldList.push({ type: 'string', value: 'productConformityStandard', text: '产品合格标准', dictCode: '' })
      fieldList.push({ type: 'string', value: 'placeOfOrigin', text: '产地', dictCode: '' })
      fieldList.push({ type: 'Text', value: 'productPresentation', text: '产品介绍', dictCode: '' })
      fieldList.push({ type: 'string', value: 'status', text: '状态', dictCode: 'record_status' })
      this.superFieldList = fieldList
    },
  },
}
</script>
<style scoped>
@import '~@assets/less/common.less';
</style>